package com.rcy.server;

import com.rcy.server.filter.InputStreamWrapperFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;

/**
 * @author RuicyWu
 * @Date 2021/11/5 19:31
 * 服务器启动入口程序
 */
@SpringBootApplication
public class ServerApplication {
    /**
     * 注册过滤器
     * @return 过滤器对象
     */
    @Bean
    @Order(1)
    public FilterRegistrationBean inputStreamWrapperFilterRegistration() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new InputStreamWrapperFilter());
        registrationBean.setName("inputStreamWrapperFilter");
        registrationBean.addUrlPatterns("/upload/*");
        return registrationBean;
    }

    public static void main(String[] args)
    {
        SpringApplication.run(ServerApplication.class,args);
    }
}
